<%@ page contentType="text/html; charset=UTF-8" import="org.apache.tomcat.dbcp.dbcp.*,java.util.*,javax.naming.*,javax.sql.*,java.sql.*"%>
<%
   ResourceBundle rbdDBConfig=ResourceBundle.getBundle("DB_Config",Locale.getDefault());
        Connection conn = null;
        BasicDataSource bds=null;
        boolean blnPool=false;
        int intActive=0;
        int intIdle=0;

        try {
            Context ctx = new InitialContext();
            Context envContext = (Context) ctx.lookup("java:/comp/env");
            DataSource ds = (DataSource) envContext.lookup(rbdDBConfig.getString("LOOKUP_NAME"));
            bds = (BasicDataSource)envContext.lookup(rbdDBConfig.getString("LOOKUP_NAME"));

            conn = ds.getConnection();

            blnPool=(conn!=null);

            if(blnPool){
              intActive=bds.getNumActive();
              intIdle=bds.getNumIdle();
            }

        } catch (Exception ex) {
            //System.out.println(this.toString().substring(this.toString().lastIndexOf('.') + 1,this.toString().lastIndexOf('@')) + ".java" +  " (getConn) Exception --> " + ex.toString());
        }
        finally{
          try{conn.close();}catch(Exception e){}
        }
 %>
<html>
<head>
<title>
TestConnPool
</title>
</head>
<body bgcolor="#ffffff">
<%if(rbdDBConfig.getString("LOOKUP_NAME")!=null && !rbdDBConfig.getString("LOOKUP_NAME").trim().equals("")){ %>
  <%if(blnPool){out.println(rbdDBConfig.getString("LOOKUP_NAME") + " use Connection Pool Successful<br/>");out.println("Connection Pool Active Num:" + intActive + "<br/>");out.println("Connection Pool Idle Num:" + intIdle + "<br/>");} %>
  <%if(!blnPool){out.println(rbdDBConfig.getString("LOOKUP_NAME") + " use Connection Pool fail");} %>
<%}else{out.println("DB_Config havn't LOOKUP_NAME");}%>
</body>
</html>
